package view.role
{
	import control.manager.MapManager;
	import control.manager.TaskManager;
	
	import data.GameConst;
	import data.MapData;
	import data.NPCData;
	import data.PlayerData;
	import data.RoleVO;
	import data.TaskVO;
	import data.UserTaskVO;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.geom.Point;
	
	import view.item.TaskStatusComplete;
	import view.item.TaskStatusHaveTask;
	import view.item.TaskStatusTasking;

	/**
	 * 地图上的NPC 
	 * @author leo
	 * 
	 */
	public class MapNPC extends MapObject
	{
		/**
		 * 是否已经完成 
		 */		
		public var isCompleteTask :Boolean = false;
		/**
		 * 是否任务进行中 
		 */		
		public var isTasking :Boolean = false;
		/**
		 * npc人物数据 
		 */		
		public var npcData :NPCData;
		/**
		 * 当前任务状态 
		 */		
		public var curTaskStatus :Sprite;

		
		public function MapNPC(npcData :NPCData)
		{
			super(npcData);
			this.npcData = npcData;
		}
		
		override public function update():void
		{
			super.update();
		}
		
		
		/**
		 * 清除任务状态 
		 * 
		 */		
		public function clearTaskStatus():void
		{
			if(this.curTaskStatus && this.curTaskStatus.parent)
			{
				this.curTaskStatus.parent.removeChild(this.curTaskStatus);
			}
		}
		/**
		 * 显示NPC的任务状态 
		 * @param status
		 * 
		 */		
		public function setTaskStatus(status :String = null):void
		{
			var mc :*;
			switch(status)
			{
				case GameConst.CAN_COMPLETE:
					mc = new TaskStatusComplete();
					changeStatus(mc);
					break;
				case GameConst.HAVE_TASK:
					mc = new TaskStatusHaveTask();
					changeStatus(mc);
					break;
				case GameConst.TASKING:
					mc = new TaskStatusTasking();
					changeStatus(mc);
					break;
			}
		}
		/**
		 * 设置状态 
		 * @param mc
		 * 
		 */		
		private function changeStatus(mc :*):void
		{
			if(curTaskStatus && curTaskStatus.parent)
			{
				curTaskStatus.parent.removeChild(this.curTaskStatus)
			}
			mc.y = this.txtRoleName.y - 10;
			this.addChild(mc);
			this.curTaskStatus = mc;
		}
		
	}
}